#ifndef TERRAIN_H
#define TERRAIN_H

#include <string>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <windows.h>
#include <SDL.h>
#include <GL/GL.h>

#include "configFileData.h"
#include "vector3.h"
#include "vector2.h"
#include "ImageIO.h"
#include "Image.h"

typedef vector3f vec3;
typedef vector2f vec2;



using namespace std;

class Terrain
{
public:
	Terrain(void);
	~Terrain(void);

	bool loadTerrainFromTGAImage(string textureImageFilePath, string imageFilePath, int terrainWidth, int terrainHeight, float vertexHeightFactor);
	void drawTerrain();

	void setTextureId(GLuint pTextureId);
	GLuint getTextureId();

private:
	int mId;
	float mVertexHeightFactor;
	GLuint mTextureId;

	SDL_Surface* mSurface;

private:
	void fillDisplayLists(Image& image, int terrainWidth, int terrainHeight);
	bool calculateVertexCoordinates(vec3* coord, vec2 initPos, int i, int j, float xDelta, float yDelta, Image& image);
	void Terrain::calculateNormalAndCoord(vec3* vertexCoordinates,vec3* normalCoordinates, vec2 initPos, int i, int j, float xDelta, float yDelta, Image& image );
	void Terrain::setTextureParameters(string pTextImagePath);

};
#endif